const express = require('express')
const mysql = require('mysql')
const db = mysql.createPool({
  host: 'localhost',
  user: 'root',
  password: '123456789',
  database: 'learner'
})

module.exports = function () {
  let router = express.Router()

  router.get('/get_banners', (req, res) => {
    db.query(`SELECT * FROM banner_table`, (err, data) => {
      if (err) {
        res.status(500).send('database error').end()
      } else {
        res.send(data).end()
      }
    })
  })

  router.get('/get_customer_evaluation_table', (req, res) => {
    db.query(`SELECT * FROM customer_evaluation_table`, (err, data) => {
      if (err) {
        res.status(500).send('database error').end()
      } else {
        res.send(data).end()
      }
    })
  })

  return router
}
